import json

from django.shortcuts import render
from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
from django.views.decorators.http import require_http_methods


@require_http_methods(['GET', 'POST'])
def get_mysql_clusters(request):
    mysql_clusters = [
        {"cluster_id": 1001, "cluster_name": "test01", "cluster_type": "MMM", "create_time": "2020-01-01",
         "cluster_desc": "this is test", "cluster_status": 0},
        {"cluster_id": 1002, "cluster_name": "test02", "cluster_type": "PXC", "create_time": "2020-02-02",
         "cluster_desc": "this is pxc", "cluster_status": 1},
    ]
    resp_data = {
        "data": mysql_clusters,
        "status": 300,
        "message": "success"
    }
    return JsonResponse(data=resp_data)


@require_http_methods(["GET"])
def show_mysql_clusters(request):
    return render(request, "mysql_ops/mysql_cluster.html")
